package com.wzm.moviepic.fragment;

import com.wzm.manager.Tag;
import com.wzm.moviepic.R;
import com.wzm.utils.UtilsTools;

import android.app.AlertDialog;
import android.content.Context;
import android.os.Bundle;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.View.OnTouchListener;
import android.widget.LinearLayout;



public class SelectDialog extends AlertDialog {
	int position;
	protected SelectDialog(Context context) {
		super(context);
		// TODO Auto-generated constructor stub
	}
	
	public SelectDialog(Context context, int theme) {
	    super(context, theme);
	}
	
	public SelectDialog(Context context, int theme,int pos) {
	    super(context, theme);
	    position = pos;
	    
	}

	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
	    super.onCreate(savedInstanceState);
	    setContentView(R.layout.mydialog);
	    
	    LinearLayout lly = (LinearLayout)findViewById(R.id.lly_click);
	    
	    switch(position)
	    {
	    case 1:
	    	lly.setBackgroundResource(R.drawable.help_movielist);
	    	break;
	    case 2:
	    	lly.setBackgroundResource(R.drawable.help_readmenu);
	    	break;
	    	default:
	    		break;
	    }
	    
   	   	lly.setOnTouchListener(new OnTouchListener() {
			
			@Override
			public boolean onTouch(View v, MotionEvent event) {
				// TODO Auto-generated method stub
				new Thread(new Runnable(){

					@Override
					public void run() {
						// TODO Auto-generated method stub
						try {
							Thread.sleep(1000);
						} catch (InterruptedException e) {
							// TODO Auto-generated catch block
							e.printStackTrace();
						}
						dismiss();
					}}).start();
				if(position==1)
				{
					UtilsTools.setTagInt(getContext(), Tag.ISLISTFIRST, 1);
				}
				if(position==2)
				{
					UtilsTools.setTagInt(getContext(), Tag.ISREADFIRST, 1);
				}
				
				return false;
			}
		});
   	   	
   	   	
	    
	   
	}
	
}
